import 'package:gold/generated/json/base/json_convert_content.dart';
import 'package:gold/model/pool_model.dart';

PoolModel $PoolModelFromJson(Map<String, dynamic> json) {
  final PoolModel poolModel = PoolModel();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    poolModel.id = id;
  }
  final int? poolId = jsonConvert.convert<int>(json['pool_id']);
  if (poolId != null) {
    poolModel.poolId = poolId;
  }
  final String? startTime = jsonConvert.convert<String>(json['start_time']);
  if (startTime != null) {
    poolModel.startTime = startTime;
  }
  final String? endTime = jsonConvert.convert<String>(json['end_time']);
  if (endTime != null) {
    poolModel.endTime = endTime;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    poolModel.name = name;
  }
  final double? totalAmount = jsonConvert.convert<double>(json['total_amount']);
  if (totalAmount != null) {
    poolModel.totalAmount = totalAmount;
  }
  final double? targetAmount = jsonConvert.convert<double>(json['target_amount']);
  if (targetAmount != null) {
    poolModel.targetAmount = targetAmount;
  }
  final String? type = jsonConvert.convert<String>(json['type']);
  if (type != null) {
    poolModel.type = type;
  }
  final int? lastCount = jsonConvert.convert<int>(json['last_count']);
  if (lastCount != null) {
    poolModel.lastCount = lastCount;
  }
  final String? lastAverage = jsonConvert.convert<String>(json['last_average']);
  if (lastAverage != null) {
    poolModel.lastAverage = lastAverage;
  }
  final String? rate = jsonConvert.convert<String>(json['rate']);
  if (rate != null) {
    poolModel.rate = rate;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    poolModel.createdAt = createdAt;
  }
  final String? updatedAt = jsonConvert.convert<String>(json['updated_at']);
  if (updatedAt != null) {
    poolModel.updatedAt = updatedAt;
  }
  return poolModel;
}

Map<String, dynamic> $PoolModelToJson(PoolModel entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['pool_id'] = entity.poolId;
  data['start_time'] = entity.startTime;
  data['end_time'] = entity.endTime;
  data['name'] = entity.name;
  data['total_amount'] = entity.totalAmount;
  data['target_amount'] = entity.targetAmount;
  data['type'] = entity.type;
  data['last_count'] = entity.lastCount;
  data['last_average'] = entity.lastAverage;
  data['rate'] = entity.rate;
  data['created_at'] = entity.createdAt;
  data['updated_at'] = entity.updatedAt;
  return data;
}

extension PoolModelExtension on PoolModel {
  PoolModel copyWith({
    int? id,
    int? poolId,
    String? startTime,
    String? endTime,
    String? name,
    double? totalAmount,
    double? targetAmount,
    String? type,
    int? lastCount,
    String? lastAverage,
    String? rate,
    String? createdAt,
    String? updatedAt,
  }) {
    return PoolModel()
      ..id = id ?? this.id
      ..poolId = poolId ?? this.poolId
      ..startTime = startTime ?? this.startTime
      ..endTime = endTime ?? this.endTime
      ..name = name ?? this.name
      ..totalAmount = totalAmount ?? this.totalAmount
      ..targetAmount = targetAmount ?? this.targetAmount
      ..type = type ?? this.type
      ..lastCount = lastCount ?? this.lastCount
      ..lastAverage = lastAverage ?? this.lastAverage
      ..rate = rate ?? this.rate
      ..createdAt = createdAt ?? this.createdAt
      ..updatedAt = updatedAt ?? this.updatedAt;
  }
}